<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/6
 * Time: 20:50
 */

use Illuminate\Database\Capsule\Manager as Capsule;

//BASE_PATH
define('BASE_PATH',__DIR__);

// Autoload 自动载入
require BASE_PATH.'/vendor/autoload.php';

// Eloquent ORM
$capsule = new Capsule();
$capsule->addConnection(require BASE_PATH.'/config/database.php');

/**
// Set the event dispatcher used by Eloquent models... (optional)
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
$capsule->setEventDispatcher(new Dispatcher(new Container));

// Make this Capsule instance available globally via static methods... (optional)
$capsule->setAsGlobal();
**/

// Setup the Eloquent ORM
$capsule->bootEloquent();

//	TIME_ZONE
$config = require BASE_PATH.'/config/config.php';
date_default_timezone_set($config['time_zone']);

if ($config['debug']){
	// whoops 错误提示
	$whoops = new \Whoops\Run;
	$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
	$whoops->register();
}else{
	ini_set('display_errors', '0');
}


// route
$route = new \Services\Route();
$route->run();